<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,viewport-fit=cover">
    <title>深i企-企业服务</title>
    <link rel="stylesheet" href="./style.css"/>
</head>
<body>
<div class="rich_content">
    <div class="header">H5转小程序</div>
    <div class="list">
        <li id="wxapp"></li>
        <li>
            <div class="text" onclick="xcx()">
                <h2>深i企</h2>
                <h3>非微信客户端</h3>
            </div>
        </li>
    </div>


</div>
<script src="//res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<script src="//www.sztv.com.cn/ysz/special_2020/js/jquery-1.8.0.min.js"></script>
<script>
//判断是否是微信浏览器的函数
var isWeiXin = function (){
  var ua = window.navigator.userAgent.toLowerCase();
  if(ua.match(/MicroMessenger/i) == 'micromessenger'){
	return true;
  }else{
    return false;
  }
}
var xcx = function () {
    window.open("weixin://dl/business/?t=H2JXDf8hZOn");
}
//如果是微信浏览器内打开
if(isWeiXin()){
	//首先授权获取小程序标签wx-open-launch-weapp的使用权
	$.ajax({
		url: "https://api.scms.sztv.com.cn/api/weixin/jstoken",
		type: "GET",
		data: "url=" + encodeURIComponent(window.location.href) + "&siteId=67",
		dataType: "jsonp",
		async: false,
		jsonpCallback: "success_jsonpCallback",
		success: function(data) {
				wx.config({
					//debug: true, 
					appId: data.appId, 
					timestamp: data.timestamp, 
					nonceStr: data.noncestr, 
					signature: data.signature, 
					jsApiList: ['onMenuShareAppMessage'],
					openTagList: ['wx-open-launch-weapp'] //获取微信小程序的标签使用权
				});
				wx.ready(function() {
					//username为需要跳转的小程序原始ID
					//path为小程序的首页路径
                    let wxApp = document.getElementById('wxapp');
                    wxApp.innerHTML = '<wx-open-launch-weapp class="wx-open-launch-weapp" id="launch-btn" username="gh_d2b06f77ef8d" path="pages/index/index">'
                                + '<template><style>.text{float:left;margin-top:24px;height:70px;-webkit-animation:.5s .2s ease both;-moz-animation:1s .2s ease both;}\n' +
                        '.text h2{font-family:"Microsoft YaHei";color:#333;text-shadow:1px 2px 4px #999;font-size:30px;font-weight:normal;-webkit-transition:0.3s all ease;-moz-transition:0.3s all ease;-ms-transition:0.3s all ease;-o-transition:0.3s all ease;}\n' +
                        '.text h3{font-family:Verdana;font-size:14px;color:#666;font-weight:normal;-webkit-transition:0.3s all ease;-moz-transition:0.3s all ease;-ms-transition:0.3s all ease;-o-transition:0.3s all ease;}\n</style><div class="text"><h2>深i企</h2><h3>微信客户端</h3></div></template></wx-open-launch-weapp>';

					var launchBtn = document.getElementById('launch-btn') ;
					if (!launchBtn) { return };
					launchBtn.addEventListener('launch', function (e) {  });
					launchBtn.addEventListener('error', function (e) {  });
				})
		}
	})
//如果是壹深圳APP或其他非微信浏览器打开
}
</script>
</body>
</html>